# todo - add support for scheduling params?
self.config = config
try:
+ # Initial domain create.
self.name = sxp.child_value(config, 'name')
self.check_name(self.name)
- try:
- self.cpu_weight = float(sxp.child_value(config, 'cpu_weight', '1'))
- except:
- raise VmError('invalid cpu weight')
- self.memory = int(sxp.child_value(config, 'memory'))
- if self.memory is None:
- raise VmError('missing memory size')
- cpu = sxp.child_value(config, 'cpu')
- if self.recreate and self.dom and cpu is not None:
- xc.domain_pincpu(self.dom, 0, 1<<int(cpu))
- try:
- image = sxp.child_value(self.config, 'image')
- self.vcpus = int(sxp.child_value(image, 'vcpus'))
- except:
- raise VmError('invalid vcpus value')
-
+ self.configure_cpus(config)
self.find_image_handler()
self.init_domain()
- self.configure_console()
+ self.register_domain()
+ self.configure_bootloader()
+
+ # Create domain devices.
self.configure_backends()
- self.construct_image()
+ self.configure_console()
self.configure_restart()
- deferred = self.configure()
- def cberr(err):
- self.destroy()
- return err
- deferred.addErrback(cberr)
- except StandardError, ex:
+ self.construct_image()
+ self.configure()
+ except Exception, ex:
# Catch errors, cleanup and re-raise.
+ print 'Domain construction error:', ex
+ import traceback
+ traceback.print_exc()
self.destroy()
raise
- return deferred
+
+ def register_domain(self):
+ xd = get_component('xen.xend.XendDomain')
+ xd._add_domain(self)
+
+ def configure_cpus(self, config):
+ try:
+ self.cpu_weight = float(sxp.child_value(config, 'cpu_weight', '1'))
+ except:
+ raise VmError('invalid cpu weight')
+ self.memory = int(sxp.child_value(config, 'memory'))
+ if self.memory is None:
+ raise VmError('missing memory size')
+ cpu = sxp.child_value(config, 'cpu')
+ if self.recreate and self.dom and cpu is not None:
- xc.domain_pincpu(self.dom, int(cpu))
++ #xc.domain_pincpu(self.dom, int(cpu))
++ xc.domain_pincpu(self.dom, 0, 1<<int(cpu))
+ try:
+ image = sxp.child_value(self.config, 'image')
+ vcpus = sxp.child_value(image, 'vcpus')
+ if vcpus:
+ self.vcpus = int(vcpus)
+ except:
+ raise VmError('invalid vcpus value')
def find_image_handler(self):
"""Construct the boot image for the domain.